home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 February / Macworld (1999-02).dmg / Shareware World / Comms & Internet / PPPop2.0.1-PPC / PPPop Scripts / Script Samples / Mail_Check Script < prev   
Text File  |  1998-10-17  |  3KB  |  114 lines

  1. --    Mail Check Version 
  2. --    Requires:
  3. --        Eudora 1.5.1 or later (Copyright QUALCOMM Incorporated)
  4. --        PPPop 1.4.1 or later
  5. --
  6. --    Based upon "Check The Mail" Copyright © 1994  Mark Alldritt
  7. --
  8. --    Modified by Rob Friefeld <mailto:friefeld@deltanet.com> 8/3/96
  9.  
  10. --    The PPP driver should be set to quiet mode for unattended operation.
  11. --    Recommended to use Okey-Dokey or another utility to answer dialogs automatically
  12.  
  13. set Setting to true -- Set to False if you are not going to launch Eudora from a setting file
  14.  
  15. if Setting then set SettingFile to "Capella:Internet:deltanet:Delta Mail:Eudora Settings" as alias
  16. --    This has to be an !!ABSOLUTE PATH!! to your setting file. This example uses my path, not yours.
  17.  
  18. try
  19.     --    Get Eudora started so it is ready to receive script commands
  20.     if Setting then
  21.         tell application "Finder"
  22.             open SettingFile
  23.         end tell
  24.     else
  25.         tell application "Eudora Pro" to run
  26.     end if
  27.     
  28.     tell application "PPPop2"
  29.         run
  30.         activate
  31.         set PPPWasUp to false
  32.         if (PPP up) then
  33.             set PPPWasUp to true
  34.         end if
  35.         if not (PPPWasUp) then
  36.             --    set some PPPop options for unattended operation, if you wish
  37.             copy launcher switch to holdlauncher
  38.             set launcher switch to false
  39.             connect
  40.             --    waste some time while the connection is established.  This is needed because MacPPP
  41.             --    operates asynchronously.
  42.             set i to 1
  43.             repeat while (i < 5000 and not (PPP up)) -- may need to increase on fast Macs
  44.                 set i to i + 1
  45.             end repeat
  46.             if not (PPP up) then
  47.                 error "PPP link not opened"
  48.             end if
  49.         end if
  50.     end tell
  51.     
  52.     
  53.     --    with timeout of 9999 seconds
  54.     tell application "Eudora Pro"
  55.         activate
  56.         connect with sending and checking
  57.     end tell
  58.     --    end timeout
  59.     
  60.     
  61.     --    Got the mail.    
  62.     --    If the PPP connection was up already, assume the user is present
  63.     --    at the computer to deal with the dialog.  Since the default choice is "don't Close"
  64.     --    the script will be well-behaved if an extension like Okey-Dokey is running.
  65.     
  66.     if PPPWasUp then
  67.         display dialog ¬
  68.             "Do you want to close the PPP link?" & return & ¬
  69.             "" buttons {"Close", "Don't Close"} default button "Don't Close" with icon caution
  70.         if button returned of the result = "close" then
  71.             tell application "PPPop2"
  72.                 activate
  73.                 disconnect
  74.             end tell
  75.         end if
  76.     else
  77.         tell application "PPPop2"
  78.             activate
  79.             disconnect
  80.             set launcher switch to holdlauncher
  81.         end tell
  82.     end if
  83.     
  84.     
  85.     --    Finish with Eudora in front
  86.     tell application "Eudora Pro"
  87.         activate
  88.     end tell
  89.     
  90. on error errorString
  91.     --    Something went wrong.  Let the user know, and offer to close the connection
  92.     --    Default is close, since if an error is encountered, we want Okey-Dokey
  93.     --    to make the right choice.
  94.     
  95.     tell application "PPPop2"
  96.         activate
  97.         if (PPP up) then
  98.             if not (PPPWasUp) then
  99.                 disconnect
  100.                 set launcher switch to holdlauncher
  101.                 set sound to holdsound
  102.                 set server to holdserver
  103.             end if
  104.         else
  105.             display dialog "Can't check the mail " & return & "(" & errorString & ")." & return & ¬
  106.                 "Close PPP link?" & return & ¬
  107.                 "" buttons {"Close", "Don't Close"} default button "Close" with icon caution
  108.             if button returned of the result = "Close" then
  109.                 disconnect
  110.             end if
  111.         end if
  112.     end tell
  113.     
  114. end try